/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Aptech.JavaXML.DOMValidator;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
 *
 * @author thanhtq
 */
public class Question {

    private String id;
    private String content;
    private String caId;

    public String getCaId() {
        return caId;
    }

    public void setCaId(String caId) {
        this.caId = caId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Cau hoi "+id+"\n-"+content;
    }


    public void createQuestionElement(Document doc) throws Exception{
        try{
            System.out.println("dfdfdf"+caId);
            Element root = doc.getDocumentElement();
            Element categoryElement = doc.createElement("question");
            categoryElement.setAttribute("id", id);

            Element contentElement = doc.createElement("Content");
            contentElement.setTextContent(content);

            Element commentElement = doc.createElement("CaID");
            commentElement.setTextContent(caId);

            categoryElement.appendChild(contentElement);
            categoryElement.appendChild(commentElement);
            doc.getDocumentElement().appendChild(categoryElement);
        }
        catch(Exception ex){
            throw ex;
        }
    }



}
